//
//  ZjypSubView.m
//  上海杨浦
//
//  Created by FrankChen on 13-3-25.
//  Copyright (c) 2013年 FrankChen. All rights reserved.
//

#import "ZjypSubView.h"

@implementation ZjypSubView

- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        // Initialization code
        //[self setBackgroundColor:[UIColor grayColor]];
        //
        
    }
    return self;
}

-(void) AddImageView:(int)flag{
    UIImageView *imageView=[[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 320, 30)];
    [imageView setBackgroundColor:[UIColor blueColor]];
    [self AddLabel:imageView:flag];
    [self addSubview:imageView];
    [imageView release];
}

-(void) AddLabel:(UIImageView *)imageView :(int)flag{
    UILabel *label=[[[UILabel alloc]initWithFrame:CGRectMake(124, 1, 80, 28)]autorelease];
    UIFont *font=[UIFont fontWithName:@"FZHTJW--GB1-0" size:18.0f];
    [label setFont:font];
    [label setBackgroundColor:[UIColor blueColor]];
    [label setTextColor:[UIColor whiteColor]];
    switch (flag) {
        case 1:{
            [label setText:@"地理位置"];
            break;}
        case 2:{
            [label setText:@"行政区划"];
            break;}
        case 3:{
            [label setText:@"经济发展"];
            break;}
        case 4:{
            [label setText:@"百年市政"];
            break;}
        case 5:{
            [label setText:@"百年工业"];
            break;}
        case 6:{
            [label setText:@"百年大学"];
            break;}
    }
    [imageView addSubview:label];
}

-(void) AddBackBtn{
    UIButton *btn_back = [UIButton buttonWithType:UIButtonTypeCustom];
    [btn_back setImage:[UIImage imageNamed:@"btn_back.png"] forState:UIControlStateNormal];
    btn_back.frame = CGRectMake(15, 1, 72, 29);
    [btn_back addTarget:self action:@selector(Btn_Back_Clicked) forControlEvents:UIControlEventTouchUpInside];
    [self addSubview:btn_back];
}

-(void)Btn_Back_Clicked{
    
    [self removeFromSuperview];
}

-(UIWebView *) AddWebViewAndGetIt{
    
    UIWebView *webView=[[[UIWebView alloc]initWithFrame:CGRectMake(0, 30, 320,400)]autorelease];

    //webView.scalesPageToFit=YES;
    [webView setBackgroundColor:[UIColor clearColor]];
    [self addSubview:webView];
    return webView;
}

-(void)showHtml:(int)flag{
    [self AddImageView:flag];
    [self AddBackBtn];
    
    UIWebView *webView=[self AddWebViewAndGetIt];
        
    NSString *resourcePath = [[NSBundle mainBundle] resourcePath];
    
    NSString *url=[[[NSString alloc]init]autorelease];
    
    switch (flag) {
        case 1:{
            url=@"diliweizhi.htm";
            break;}
        case 2:{
            url=@"xingzhengqvhua.htm";
            break;}
        case 3:{
            url=@"jingjifazhan.htm";
            break;}
        case 4:{
            url=@"bainianshizheng.html";
            break;}
        case 5:{
            url=@"bainiangongye.html";
            break;}
        case 6:{
            url=@"bainiandaxue.html";
            break;}
    }
    NSString *filePath =[resourcePath stringByAppendingPathComponent:url];
    
    NSString *htmlstring=[[[NSString alloc] initWithContentsOfFile:filePath  encoding:NSUTF8StringEncoding error:nil]autorelease];
    [webView loadHTMLString:htmlstring baseURL:[NSURL fileURLWithPath:[ [NSBundle mainBundle] bundlePath]]];
}


/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect
{
    // Drawing code
}
*/

@end










